<?php
// +----------------------------------------------------------------------
// | Yzncms [ 御宅男工作室 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2018 http://yzncms.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | fastadmin: https://www.fastadmin.net/
// +----------------------------------------------------------------------

// +----------------------------------------------------------------------
// | 手机短信接口
// +----------------------------------------------------------------------
namespace app\api\controller;

use app\api\model\AccessTokenModel;
use app\api\model\DouYinService;
use app\api\model\Token;
use app\common\controller\Api;
use app\common\library\Sms as Smslib;
use app\common\model\DouyinModel;
use app\common\model\StaffModel;
use think\Db;
use think\Exception;
use think\facade\Hook;
use think\facade\Validate;
use think\Request;
use util\Http;

/**
 * @title 授权登陆
 * @controller api\controller\Sms
 * @group base
 */
class Login extends Api
{
    protected $noNeedLogin = ['*'];

    //注册
    public function register()
    {
        $data = (new StaffModel())->register($this->request_array);
        $data['code'] == 200 ? $this->success($data['msg'],$data['data']) : $this->error($data['msg']);
    }

    public function  login(){
        $data = (new StaffModel())->login($this->request_array);
        $data['code'] == 200 ? $this->success($data['msg'],$data['data']) : $this->error($data['msg']);
    }


    const URL_TOKEN = 'https://open-api.ixigua.com/oauth/access_token/';
    const DOUYIN_URL = 'https://open.douyin.com';

    public function GetLoginQrcode()
    {
        $config = config('config_douyin.dy_program');
        $url = self::DOUYIN_URL . '/platform/oauth/connect';
        $redirect_uri = config('app.api_url');
        $scope = "user_info,video.data.bind,";
        $url = $url . "?client_key=" . $config['client_key'] . "&response_type=code&scope=" . $scope . "&redirect_uri=" . $redirect_uri . "&state=1";
        header('Location:' . $url);
        exit();
    }

    /**
     * @title 登陆
     */



}
